package td;

import java.util.HashSet;

public abstract class Tower extends FieldElement {
	protected int range;
	public MagicStones[] stones;
	protected Bullet bullet;
	protected float speed;
	protected int cost;
	protected int sliceChance;
	/*Set for the Fields in range*/
	protected HashSet<Field> inrange;
	public boolean fogged;
	
	/*Constructor of Tower class*/
	public Tower(){
		super();
		stones = new MagicStones[2];
		sliceChance = 10;
		inrange = new HashSet<Field>();
	}
	
	public Tower(Field position) {
		super(position);
		stones = new MagicStones[2];
		sliceChance = 10;
		inrange = new HashSet<Field>();
		inRange(position,0);
	}

	public abstract void shoot(Enemy target);

	public abstract void upgrade(MagicStones stone, int stoneplace);

	public abstract void degrade(int stoneplace);

	public abstract void applyFog();

	public abstract void removeFog();
	
	/*Shooting a cutter bullet which cuts the enemy to two pieces*/
	public void shootCutter(Enemy target){
		CutterBullet cutbullet = new CutterBullet(this.bullet.damage, StatusEffects.None);
		target.getHurt(cutbullet);
	}
	
	/*Recursive method to get the Fields in range*/
	public void inRange(Field position, int r)
	{		
		int lvl = r;
		inrange.addAll(position.neighbours);
		lvl++;
		if(lvl<range+1)
		{
			for(int i=0; i<position.neighbours.size(); i++)
			{
				this.inRange(position.neighbours.get(i), lvl);
			}
		}
	}

	/*Returns the cost of the current tower*/
	public int getCost() {
		return cost;
	}
}
